﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessObjects.BO_GetObjects;
using LibraryO2S;
using BusinessObjects;



public partial class controls_admin_ADSExpires : Pages_Base
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        if (!IsPostBack)
        {
            if (Request["l_day"] != null)
                loadAdv(Convert.ToInt32(Request["l_day"]));
        }
    }
    private void loadAdv(int l_day)
    {
        try
        {
            base.OpenConnection();
            DataTable objDT = BO_Ads_Picture.Expires(l_day);
            bindRepeater(rptPicture, objDT, divMessage);
        }
        catch (Exception ex)
        {
            //throw ex;
            divMessage.InnerHtml = O2S_Message.Error("Lỗi", "Phát hiện lỗi trong quá trình xử lý<br />" + ex.Message + ex.Source);
        }
        finally { base.CloseConnection(); }
    }
    protected void rptPicture_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            base.OpenConnection();
            Button btnID = (Button)e.Item.FindControl("btnID");
            string commandName = e.CommandName;
            int picture_id = Convert.ToInt32(btnID.CommandArgument);
            if (commandName.Equals("del"))
            {
                BO_Ads_Picture.Delete(picture_id);
                divMessage.InnerHtml = O2S_Message.Success("Thông Báo", "Xóa thành công .");
            }
            else if (commandName.Equals("edit"))
                Response.Redirect("Default.aspx?module=AdvPictureAction&a_id=" + picture_id);
            if (Request["l_day"] != null)
                loadAdv(Convert.ToInt32(Request["l_day"]));
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = O2S_Message.Error("Lỗi", "Phát hiện lỗi: <br />" + ex.Message + ex.Source);
        }
        finally { base.CloseConnection(); }
    }
    protected void btnAdv_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx?module=AdvPicture");
    }
    protected void btnContact_Click(object sender, EventArgs e)
    {

    }
}
